#include "ConcreteConnector.h"


ConcreteConnector::ConcreteConnector(IReactor<SOCKET>* _reactor):IConnector(_reactor)
{

}


ConcreteConnector::~ConcreteConnector(void)
{

}

void ConcreteConnector::connect_service_handle(ServiceHandler<SOCKET>* serviceHand, INET_Addr* addr)
{
	service = serviceHand;	
	stream.set_handle((serviceHand->get_handle()).getConnection());
	connector = SOCK_Connector();
	connector.connect(*addr, stream);
	handle.setConnection(stream.get_handle());
	reactor->register_handler(this, INIT_EVENT);
}

void ConcreteConnector::complete(Handler<SOCKET> handle)
{
	reactor->remove_handler(handle,INIT_EVENT);
	service->open(&stream);
}

void ConcreteConnector::activate_service_handle(ServiceHandler<SOCKET>& serviceHand)
{
	
}